package logic

import (
	"context"
	"merchantmanager/models/mysql"

	"merchantmanager/merrpc/internal/svc"
	"merchantmanager/merrpc/merrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type MerShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewMerShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MerShowLogic {
	return &MerShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *MerShowLogic) MerShow(in *merrpc.MerShowRequest) (*merrpc.MerShowResponse, error) {
	// todo: add your logic here and delete this line
	var mer mysql.Merchants
	mysql.DB.Debug().Where("id =?", in.Id).Find(&mer)
	return &merrpc.MerShowResponse{
		Id:    int64(mer.ID),
		Name:  mer.Name,
		Price: float32(mer.Price),
		Image: int64(mer.Image),
	}, nil

}
